// snake.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "mySnake.h"
#include "highgui.h"

int main(int argc, char* argv[])
{
//	printf("Hello World!\n");

	IplImage* bgImg = cvLoadImage("pic\\bj.jpg",1);
	cvNamedWindow("image");
	IplImage* showImage = cvCreateImage(
		cvSize(bgImg->width,bgImg->height), IPL_DEPTH_8U, 3);

	CmySnake snake;
	//
	snake.init();
	char key = 'b';
	while(key!='a')
	{
		cvCopy(bgImg,showImage);
		snake.drawToBack(showImage);
		
		cvShowImage("image",showImage);
		key = cvWaitKey(100);
		snake.m_lenght = (snake.m_lenght + 1)%8;

		snake.m_posY += 20;
		if (snake.m_posY >400) snake.m_posY = 400;


	}


	

	cvDestroyWindow("image");
	cvReleaseImage(&showImage);
	cvReleaseImage(&bgImg);

	return 0;
}

